package com.ms.game.itembox.db;

import java.math.BigDecimal;
import java.util.ArrayList;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.ms.game.common.GameType;
import com.ms.game.itembox.GameCardType;
import com.ms.game.itembox.container.ItemDrawInfo;
import com.ms.game.itembox.container.ItemJsonContent;
import com.xpec.c4.db.model.basic.BasicModel;


@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name = ItemBoxModel.TABLENAME)
public class ItemBoxModel extends BasicModel{
	
	public final static String TABLENAME = "itembox";

	private static final long serialVersionUID = -7337625669930291058L;
	
	// -------- 基本區 ---------
	/** 道具ID */
	private String itemId;
	
	/** 是否開放此道具使用*/
	private boolean open;
	
	/** 給分析server使用時，是否要用default Id*/
	private boolean analysisUseDefaultId;
	
	/** 原本的itemid */
	private String defaultItemId;

	/** 是否是預設的道具 */
	private boolean defaultItem;

	/** 是否額外設定 */
	private boolean additionalSetting;

	/** 道具class */
	private int classId;

	/** 物品的class name(反射用) */
	private String itemClassName;

	/** 道具類型 */
	private int type;

	/** 道具圖片 */
	private String iconId;

	/** 道具名稱 (Server看) */
	private String defaultName;

	/** 道具名稱 (給Client顯示) */
	private String name;

	/** 道具描述 */
	private String functionDesc;
	
	/** 是否可以交易*/
	private boolean canTrade;

	/** 此道具是否可以精煉 */
	private boolean canRefine;

	/** 道具基本精煉等級 */
	private int itemRefineLevel;

	/** 需要送去DC才能得到效果 */
	private boolean applyItemToDc;

	/** 需要目標 */
	private boolean needTarget;

	/** 是否可以堆疊 */
	private boolean stackable;

	/** 精煉過期時間 (小時) */
	private int refineExpireTime;

	/** 使用等級 */
	private int useLevel;

	/** 使用vip等級*/
	private int useVipLevel;
	
	/**
	 * 各精煉等級需要的水晶數量<br>
	 * index 0: 精煉到1級需要的水晶數量<br>
	 * index 1: 精煉到2級需要的水晶數量<br>
	 */
	private ArrayList<Integer> refineCrystalCostList = new ArrayList<Integer> ();
	
	/**  精煉後，每等級代表的押注額  */
	private ArrayList<Integer> refineLevelBetCount = new ArrayList<Integer> ();
	
	/** 是否有過期時間*/
	private boolean hasExpireTime;
	
	/** 過期時間*/
	private int expireTime;
	
	//------------ 給 client  ------------------
	private String animationId;
	
	//-------------  C幣卡   -----------------
	/** 多少C幣*/
	private int goldCoin;
	
	//------------ 水晶 --------------------
	/** 水晶的數量*/
	private int crystalCount;
	
	//-------------  禁言卡   ----------------
	/** 持續時間 (秒) */
	private int durationSec;
	
	//------------ 機台卡  ------------------
	/** 使用遊戲 */
	private GameType useGame;
	
	/** 機台卡類型 */
	private GameCardType gameCardType;
	
	/** 不能使用的遊戲 */
	private ArrayList<String> notUseGames;
	
	/** 使用館別 */
	private String useHall;
	
	/** 幣值比 */
	private BigDecimal gainRate = BigDecimal.ONE;
	
	//------------ 送道具類型 ------------
	/** 隨機道具列表  因為要設定權重跟總數 所以用 iteminfo*/
	private ArrayList<ItemDrawInfo> randomItemList;
	
	/** 固定道具列表 因為只需要數量 所以用 ItemJsonContent*/
	private ArrayList<ItemJsonContent> fixItemList;
	
	/** 固定道具列表 (給client)*/
	private String fixItemListClient;
	
	/** 超過設定的 vip 等級，可以額外獲得的物品*/
	private int extraGetVipLevel;
	
	/** 到達 extraGetVipLevel ， 可以額外獲得的物品*/
	private ArrayList<ItemJsonContent> vipExtraGetItemList;
	
	/** 到達 extraGetVipLevel ， 可以額外獲得的物品 (給Client)*/
	private String vipExtraGetItemListClient;
	
	//------------ 寶箱 ------------
	/** 寶箱類型 */
	private byte treasureBoxType;
	
	//------------  升級卡  ------------
	/** 可以增加的等級*/
	private int upgradeLevel;
	
	@Id
	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public boolean isOpen() {
		return open;
	}

	public void setOpen(boolean open) {
		this.open = open;
	}

	public boolean isAnalysisUseDefaultId() {
		return analysisUseDefaultId;
	}

	public void setAnalysisUseDefaultId(boolean analysisUseDefaultId) {
		this.analysisUseDefaultId = analysisUseDefaultId;
	}

	@Column(nullable = false)
	public String getDefaultItemId() {
		return defaultItemId;
	}

	public void setDefaultItemId(String defaultItemId) {
		this.defaultItemId = defaultItemId;
	}

	public boolean isDefaultItem() {
		return defaultItem;
	}

	public void setDefaultItem(boolean defaultItem) {
		this.defaultItem = defaultItem;
	}

	public boolean isAdditionalSetting() {
		return additionalSetting;
	}

	public void setAdditionalSetting(boolean additionalSetting) {
		this.additionalSetting = additionalSetting;
	}

	@Column(nullable = false)
	public int getClassId() {
		return classId;
	}

	public void setClassId(int classId) {
		this.classId = classId;
	}

	public String getItemClassName() {
		return itemClassName;
	}

	public void setItemClassName(String itemClassName) {
		this.itemClassName = itemClassName;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	@Column(nullable = false)
	public String getIconId() {
		return iconId;
	}

	public void setIconId(String iconId) {
		this.iconId = iconId;
	}

	public String getDefaultName() {
		return defaultName;
	}

	public void setDefaultName(String defaultName) {
		this.defaultName = defaultName;
	}

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(nullable = false)
	public String getFunctionDesc() {
		return functionDesc;
	}

	public void setFunctionDesc(String functionDesc) {
		this.functionDesc = functionDesc;
	}

	public boolean isCanTrade() {
		return canTrade;
	}

	public void setCanTrade(boolean canTrade) {
		this.canTrade = canTrade;
	}

	public boolean isNeedTarget() {
		return needTarget;
	}

	public void setNeedTarget(boolean needTarget) {
		this.needTarget = needTarget;
	}

	public boolean isStackable() {
		return stackable;
	}

	public void setStackable(boolean stackable) {
		this.stackable = stackable;
	}

	public int getRefineExpireTime() {
		return refineExpireTime;
	}

	public void setRefineExpireTime(int refineExpireTime) {
		this.refineExpireTime = refineExpireTime;
	}

	@Type(type = "com.xpec.c4.db.usertype.IntegerListJsonType")
	public ArrayList<Integer> getRefineCrystalCostList() {
		return refineCrystalCostList;
	}

	public void setRefineCrystalCostList(ArrayList<Integer> refineCrystalCostList) {
		this.refineCrystalCostList = refineCrystalCostList;
	}

	@Type(type = "com.xpec.c4.db.usertype.IntegerListJsonType")
	public ArrayList<Integer> getRefineLevelBetCount() {
		return refineLevelBetCount;
	}

	public boolean isApplyItemToDc() {
		return applyItemToDc;
	}

	public void setApplyItemToDc(boolean applyItemToDc) {
		this.applyItemToDc = applyItemToDc;
	}

	public void setRefineLevelBetCount(ArrayList<Integer> refineLevelBetCount) {
		this.refineLevelBetCount = refineLevelBetCount;
	}

	public int getGoldCoin() {
		return goldCoin;
	}

	public void setGoldCoin(int goldCoin) {
		this.goldCoin = goldCoin;
	}

	public boolean isHasExpireTime() {
		return hasExpireTime;
	}

	public void setHasExpireTime(boolean hasExpireTime) {
		this.hasExpireTime = hasExpireTime;
	}

	public int getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(int expireTime) {
		this.expireTime = expireTime;
	}

	@Enumerated(EnumType.STRING)
	public GameType getUseGame() {
		return useGame;
	}

	public void setUseGame(GameType useGame) {
		this.useGame = useGame;
	}

	@Enumerated(EnumType.STRING)
	public GameCardType getGameCardType() {
		return gameCardType;
	}

	public void setGameCardType(GameCardType gameCardType) {
		this.gameCardType = gameCardType;
	}
	
	@Type(type = "com.xpec.c4.db.usertype.StringListJsonType")
	public ArrayList<String> getNotUseGames() {
		return notUseGames;
	}

	public void setNotUseGames(ArrayList<String> notUseGames) {
		this.notUseGames = notUseGames;
	}

	
	@Type(type = "com.xpec.c4.db.usertype.item.ItemDrawInfoListUserType")
	public ArrayList<ItemDrawInfo> getRandomItemList() {
		return randomItemList;
	}

	public void setRandomItemList(ArrayList<ItemDrawInfo> randomItemList) {
		this.randomItemList = randomItemList;
	}
	
	@Type(type = "com.xpec.c4.db.usertype.item.ItemJsonContentListUserType")
	public ArrayList<ItemJsonContent> getFixItemList() {
		return fixItemList;
	}

	public void setFixItemList(ArrayList<ItemJsonContent> fixItemList) {
		this.fixItemList = fixItemList;
	}
	
	@Column(columnDefinition="TEXT")
	public String getFixItemListClient() {
		return fixItemListClient;
	}

	public void setFixItemListClient(String fixItemListClient) {
		this.fixItemListClient = fixItemListClient;
	}
	
	public int getExtraGetVipLevel() {
		return extraGetVipLevel;
	}

	public void setExtraGetVipLevel(int extraGetVipLevel) {
		this.extraGetVipLevel = extraGetVipLevel;
	}

	@Type(type = "com.xpec.c4.db.usertype.item.ItemJsonContentListUserType")
	public ArrayList<ItemJsonContent> getVipExtraGetItemList() {
		return vipExtraGetItemList;
	}

	public void setVipExtraGetItemList(ArrayList<ItemJsonContent> vipExtraGetItemList) {
		this.vipExtraGetItemList = vipExtraGetItemList;
	}

	public int getDurationSec() {
		return durationSec;
	}

	public void setDurationSec(int durationSec) {
		this.durationSec = durationSec;
	}

	public boolean isCanRefine() {
		return canRefine;
	}

	public void setCanRefine(boolean canRefine) {
		this.canRefine = canRefine;
	}

	public int getItemRefineLevel() {
		return itemRefineLevel;
	}

	public void setItemRefineLevel(int itemRefineLevel) {
		this.itemRefineLevel = itemRefineLevel;
	}

	public int getUpgradeLevel() {
		return upgradeLevel;
	}

	public void setUpgradeLevel(int upgradeLevel) {
		this.upgradeLevel = upgradeLevel;
	}

	public String getAnimationId() {
		return animationId;
	}

	public void setAnimationId(String animationId) {
		this.animationId = animationId;
	}

	public int getCrystalCount() {
		return crystalCount;
	}

	public void setCrystalCount(int crystalCount) {
		this.crystalCount = crystalCount;
	}

	public int getUseLevel() {
		return useLevel;
	}

	public void setUseLevel(int useLevel) {
		this.useLevel = useLevel;
	}

	public int getUseVipLevel() {
		return useVipLevel;
	}

	public void setUseVipLevel(int useVipLevel) {
		this.useVipLevel = useVipLevel;
	}

	public byte getTreasureBoxType() {
		return treasureBoxType;
	}

	public void setTreasureBoxType(byte treasureBoxType) {
		this.treasureBoxType = treasureBoxType;
	}
	
	public String getVipExtraGetItemListClient() {
		return vipExtraGetItemListClient;
	}

	public void setVipExtraGetItemListClient(String vipExtraGetItemListClient) {
		this.vipExtraGetItemListClient = vipExtraGetItemListClient;
	}
	
	public String getUseHall() {
		return useHall;
	}

	public void setUseHall(String useHall) {
		this.useHall = useHall;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 1.0")
	public BigDecimal getGainRate() {
		return gainRate;
	}

	public void setGainRate(BigDecimal gainRate) {
		this.gainRate = gainRate;
	}
	
}
